<template>
    <div id="root">
        <div class="header">
            <!--            导航条-->
            <nav class="nav navbar navbar-inverse">
                <a href="###" class="navbar-brand pull-left">购物车</a>
                <p class="pull-right navbar-text">
                    你的购物车当前有{{totalCount}}件商品,总共{{totalPrice}}元
                    <button class="btn btn-danger" @click="$router.push('/cart').catch(()=>{})">购物车</button>
                </p>
            </nav>
        </div>
    </div>
</template>
<script>
    export default {
        name: "Header",
        props: ["cart-array"],
        computed: {
            // totalCount(){
            //     let  count=0;
            //     for(let i in this.cartArray){
            //         let obj=this.cartArray[i];
            //         count+=parseInt(obj.count);
            //     }
            //     return count;
            // },
            totalCount() {


            },
            totalPrice() {
                let pirce = 0;
                for (let i in this.cartArray) {
                    let obj = this.cartArray[i];
                    let proOBj = obj.pro;
                    pirce += parseInt(obj.count) * proOBj.proPrice;
                }
                return pirce;
            },

        },
        created() {
            console.log("哇哈哈");
            console.log(this.axios);
            this.axios.get("/api/look").then(data => {
                console.log(data.data)
            }).catch(err => {
            })
        }
    }
</script>

<style scoped>

</style>